import moment from 'moment';

let defaultState = {
    sateData: !!localStorage['sateData'] ? JSON.parse(localStorage['sateData']) : [],
    checked: true,
    startTime: moment().subtract(2, 'hour'),
    endTime: moment(),
};

function classifyReducer(state=defaultState, action){
    switch (action.type) {
        case "classify":
            addSateData(action.data);
            return Object.assign({},state,action.data);
        case 'changeStart':
            return Object.assign({},state,action.data);
        case 'changeEnd':
            return Object.assign({},state,action.data);
        case 'changeType':
            return Object.assign({},state,action.data);
        default:
            return state;
    }
}
export default classifyReducer;

//添加卫星产品数据‘
function addSateData(data){
    localStorage['sateData'] = JSON.stringify(data.sateData);
}